/* Exit status values */
#define WRITE_SUCCESS 0
#define WRITE_FAILURE 1
#define INPUT_ERROR 2

static const int flen=sizeof(float);
static const int dlen=sizeof(double);

static const int blen=sizeof(UCHAR);

static const int ilen=sizeof(short);
static const int uilen=sizeof(unsigned short);

static const int llen=sizeof(IDL_LONG);
static const int ullen=sizeof(IDL_ULONG);

static const int l64len=sizeof(IDL_LONG64);
static const int ul64len=sizeof(IDL_ULONG64);

static const int slen=sizeof(IDL_STRING);


int
aw_print(int idlType, UCHAR *tptr);

void
aw_error(char *text, char *errMessage);

static void
aw_set_status(int statusVal);

int aw_nparams(int argc);

typedef struct {
  IDL_KW_RESULT_FIRST_FIELD; /* Must be first entry in structure */

  /* These must be in alpabetical order */

  int append;
  int append_there;

  int bracket_arrays;
  int bracket_arrays_there;

  IDL_STRING delimiter;
  int delimiter_there;

  /* Status of the call */
  IDL_VPTR status;
  int status_there;

  int verbose;
  int verbose_there;

} KW_RESULT;

static IDL_KW_PAR kw_pars[] = {

  IDL_KW_FAST_SCAN, 

  /* These must be in alphabetical order */

  /* 
     IDL_KW_VIN: can be just an input, like var=3
     IDL_KW_OUT: can be output variable, var=var
     IDL_KW_ZERO: If not there, variable is set to 0

     If the VIN is set, then the _there variables will be
     0 when an undefined name variable is sent: no good for
     returning variables!
  */

  {"APPEND", IDL_TYP_INT, 1, 0, 
   IDL_KW_OFFSETOF(append_there), IDL_KW_OFFSETOF(append) },

  {"BRACKET_ARRAYS", IDL_TYP_INT, 1, 0, 
   IDL_KW_OFFSETOF(bracket_arrays_there), IDL_KW_OFFSETOF(bracket_arrays) },

  {"DELIMITER", IDL_TYP_STRING, 1, 0, 
   IDL_KW_OFFSETOF(delimiter_there), IDL_KW_OFFSETOF(delimiter) },


  {"STATUS", IDL_TYP_UNDEF, 1, IDL_KW_OUT | IDL_KW_ZERO, 
   IDL_KW_OFFSETOF(status_there), IDL_KW_OFFSETOF(status) },

  {"VERBOSE", IDL_TYP_INT, 1, 0, 
   IDL_KW_OFFSETOF(verbose_there), IDL_KW_OFFSETOF(verbose) },

  { NULL }
};
